package com.ewhale.feitengguest.ui.user.mine.adapter;

import android.content.Context;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.ewhale.feitengguest.R;
import com.simga.library.adapter.MBaseAdapter;
import com.simga.library.widget.BGButton;

import java.util.List;

import androidx.core.content.ContextCompat;
import butterknife.BindView;
import butterknife.ButterKnife;

public class WithdrawAdapter extends MBaseAdapter<Integer> {

    public double balance;

    public WithdrawAdapter(Context context, List<Integer> data) {
        super(context, data, R.layout.item_withdraw);
    }

    @Override
    protected void newView(View convertView, int position) {
        convertView.setTag(new ViewHolder(convertView));
    }

    @Override
    protected void holderView(View convertView, Integer itemObject, int position) {
        ViewHolder holder = (ViewHolder) convertView.getTag();
        if(itemObject == 1){
            holder.mTvTixian.setText("自动提现");
            holder.btnNew.setVisibility(View.VISIBLE);
        }else{
            holder.mTvTixian.setText("立即提现");
            holder.btnNew.setVisibility(View.GONE);
        }
        holder.mTvPrice.setText(itemObject+"元");
        if(balance<itemObject){
            holder.mLlPriceBg.setBackgroundResource(R.mipmap.d2_bg_tixian_n);
            holder.mTvPrice.setTextColor(ContextCompat.getColor(mContext,R.color.text_999999));
            holder.mTvTixian.setTextColor(ContextCompat.getColor(mContext,R.color.text_999999));
        }else{
            holder.mLlPriceBg.setBackgroundResource(R.mipmap.d2_bg_tixian_s);
            holder.mTvPrice.setTextColor(ContextCompat.getColor(mContext,R.color.text_333333));
            holder.mTvTixian.setTextColor(ContextCompat.getColor(mContext,R.color.text_333333));
        }
    }

    class ViewHolder {
        @BindView(R.id.tv_price)
        TextView mTvPrice;
        @BindView(R.id.tv_tixian)
        TextView mTvTixian;
        @BindView(R.id.ll_priceBg)
        LinearLayout mLlPriceBg;
        @BindView(R.id.btn_new)
        BGButton btnNew;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
